<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../day54/jquery-3.6.0.min.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .box {
            width: 200px;
            height: 200px;
            background-color: #6ff;
            margin: 50px;
            overflow: hidden;
            padding: 10px;
            border: 2px solid #333;
            /* display: none; */
        }
    </style>
</head>
<body>
    <button>get</button>
    <button>post</button>
    <button>jsonp</button>
</body>
<script>
    console.log($);  //对构造函数进行了二次封装

    // $.ajax

    $("button").eq(0).click(function(){
        $.ajax({
            type:"get",
            url:"http://192.168.60.133/2111_php/demo_30/php/searchGradeOrderLimit.php",
            data:{
                key:"",
                orderCol:"id",
                orderType:"asc",
                pageIndex:1,
                showNum:20,
            },
            dataType:"json",
            success:function(data){
                console.log(data);
            }
        })

        // $.get("http://192.168.60.133/2111_php/demo_30/php/searchGradeOrderLimit.php", {
        //     key: "",
        //     orderCol: "id",
        //     orderType: "asc",
        //     pageIndex: 1,
        //     showNum: 20,
        // }, function (data) {
        //     console.log(data);
        // }, "json")
    });

    $("button").eq(1).click(function(){
        $.ajax({
            type:"post",
            url:"http://192.168.60.133/2111_php/demo_30/php/login.php",
            data:{
                user:"a123123",
                pwd:123123,
            },
            dataType:"json",
            success:function(data){
                console.log(data);
            }
        })

        // $.post("http://192.168.60.133/2111_php/demo_30/php/login.php", {
        //     user: "a123123",
        //     pwd: 123123,
        // }, function (data) {
        //     console.log(data);
        // }, "json")
    })

    $("button").eq(2).click(function(){
        $.ajax({
            type:"post",
            url:"http://192.168.60.133/2111_php/jsonp/searchGradeOrderLimit.php",
            data:{
                key:"",
                orderCol:"id",
                orderType:"asc",
                pageIndex:1,
                showNum:20,
            },
            jsonp: "cb", // 执行接收回调函数 字段名(默认callback)
            jsonpCallback: "fn",  // 指定接收数据的回调函数名 (默认随机生成  jsonp_123123123123)
            // 组合  cb=fn
            dataType: "jsonp",  // 当前以jsonp的形式发送请求
            success: function (data) {
                console.log(data);
            }
        })


        // 您可以通过使用JSONP形式的回调函数来加载其他网域的JSON数据
        $.getJSON("http://192.168.60.133/2111_php/jsonp/searchGradeOrderLimit.php?cb=?", {
            key: "",
            orderCol: "id",
            orderType: "asc",
            pageIndex: 1,
            showNum: 20,
        }, function (data) {
            console.log(data);
        })
    })
</script>
</html>